'use strict'
const fs = require('fs')
class elifeadd{

    constructor (mdb) {
        this.db = mdb
    }

    makeId () {
        return `u_${Date.now().toString(16)}${parseInt(Math.random()*10000) + 11111}`
      }

    async insert(data){

        let id = this.makeId()

        let sql =  'INSERT INTO app(id,appname,image) VALUES ($1, $2, $3)'
        let ret = await this.db.query(sql, [
            id, data.appname, data.image
        ])
        if (ret.rowCount <= 0) {
            return false
          }
        return id;
    }
}

module.exports = elifeadd